#pragma once


#include <memory>
#include <filesystem>

#include "memdb/memdb.h"

namespace memdb {
namespace impl {

class IMeta;
class IData;

}//namespace impl
}//namespace memdb


namespace memdb {
namespace impl {
namespace simple {

class SimpleTable : public ITable {
public:
  SimpleTable(IMeta & meta, std::unique_ptr<IData> data);
  ~SimpleTable() override;

  std::error_code get(const KeyType & key, std::string & value) const override;
  std::error_code insert(const KeyType & key, const KeyType & value) override;
  std::error_code remove(const KeyType & key) override;

  std::error_code update(const KeyType & key, const KeyType & value) override;
  std::error_code replace(const KeyType & key, const KeyType & value) override;
  std::error_code update(const KeyType & key, const KeyType & value, std::string & old) override;
  std::pair<std::error_code, bool> replace(const KeyType & key, const KeyType & value, std::string & old) override; 

  size_t count() const override ;

  std::unique_ptr<Iterator> iterator() const override ;
  std::unique_ptr<Iterator> range(size_t offset, size_t len) const override ;
  std::unique_ptr<Iterator> findRange(const KeyType & key, size_t offset, size_t len) const override;

  
private:
  IMeta & _meta;
  std::unique_ptr<memdb::impl::IData> _data;
};


}//namespace simple
}//namespace impl
}//namespace memdb
